﻿Imports Negocio
Imports Utilitario
Public Class frmMotivoRebote

    Dim servicio As New DocumentoClienteNegocio

    Dim pedido As String = ""
    Dim motivo As String = ""
    Dim obser As String = ""

    Sub New(codPedido As String, codMotivo As String, observacion As String)

        ' Llamada necesaria para el diseñador.
        InitializeComponent()

        ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
        Me.pedido = codPedido
        Me.motivo = codMotivo
        Me.obser = observacion
    End Sub

    Private Sub frmMotivoRebote_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.Text = "Motivo de Rebote - " & pedido
        cargarMotivos()
        txtObservMotivo.Text = obser
    End Sub

    Sub cargarMotivos()
        Dim ds As DataSet = servicio.listarMotivosRebote(motivo)
        With cboMotivo
            .DataSource = ds.Tables(0)
            .ValueMember = "MOR_Codigo"
            .DisplayMember = "MOR_Descripcion"
        End With
    End Sub

    Private Sub btnGuardar_Click(sender As System.Object, e As System.EventArgs) Handles btnGuardar.Click
        codigoMotivo = cboMotivo.SelectedValue.ToString
        Dim dt As DataSet = servicio.listarMotivosRebote(codigoMotivo)
        descMotivo = dt.Tables(0).Rows(0)("MOR_Descripcion").ToString.Trim
        obsMotivo = txtObservMotivo.Text.Trim
        DialogResult = Windows.Forms.DialogResult.OK
    End Sub

End Class